<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>签到签退信息查询表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>

</head>

<body onload="loadData()">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>信息查询</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">

            <input type="text" name="username"  placeholder="请输入用户名" autocomplete="off" class="layui-input">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <%-- <xblock>

         <button class="layui-btn" onclick="x_admin_show('添加用户','./admin-add.html')"><i class="layui-icon"></i>添加</button>
         <span class="x-right" style="line-height:40px">共有数据：1 条</span>
     </xblock>--%>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>员工编号</th>
            <th>用户名</th>
            <th>部门</th>
            <th>职位</th>
            <th>电话</th>
            <th>迟到时间</th>
            <th>迟到</th>
            <th>早退时间</th>
            <th>早退</th>

            <th>操作</th>
        </thead>
        <tbody id="tb">

        <tr>
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <input type="button" class="btn btn-success btn-sm" onclick="loadData()" value="查询">


            <td class="td-manage">

                <a title="编辑"  onclick="x_admin_show('编辑','admin-edit.html')" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>

    <div class="page">
        <div>
            <a class="prev" href="">&lt;&lt;</a>

            <span class="current">1</span>

            <a class="next" href="">&gt;&gt;</a>
        </div>
    </div>

</div>
<script>
    //加载数据
    function loadData() {

        $.ajax({
            url :"${pageContext.request.contextPath}/ess",
            type:"get",
            //  data:{"eNumber":eNumber,"name":name,"depa":depa,"job":job,"phone":phone,"time":time,"state":state,"time1":time1,"state1":state1},
            dataType:"json",
            success:function (data) {
                console.log(data);
                console.log(typeof(data.info));
                if(typeof(data.info)=='string'){
                    alert(data.info);
                    //清空
                    $("#tb").html(data.info);
                }else{
                    var html = "";
                    for(var i=0;i<data.info.length;i++){
                        html += "<tr>" +"<td>"+
                            "<td>"+data.info[i].eNumber+"</td>" +
                            "<td>"+data.info[i].name+"</td>" +
                            "<td>"+data.info[i].depa+"</td>" +
                            "<td>"+data.info[i].job+"</td>" +
                            "<td>"+data.info[i].phone+"</td>" +
                            "<td>"+data.info[i].list1[0].time+"</td>" +
                            "<td>"+data.info[i].list1[0].state+"</td>" +
                            "<td>"+data.info[i].list2[0].time+"</td>" +
                            "<td>"+data.info[i].list2[0].state+"</td>" +
                            "<td><button type='button' class=\"btn btn-success btn-sm\" onclick='updatePage(this)'>修改</button></td>" +
                            "</tr>";
                    }

                    $("#tb").html(html);
                }


            }
        })
    }

    //打开修改页面
    function updatePage(obj) {
        var id = $(obj).parent().parent().find("td").eq(0).text();
        console.log(id);
        window.location.href="${pageContext.request.contextPath}/admin/edit?sysId="+id;
    }


    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }


</script>

</body>

</html>